![]() | Deployment Architecture (Ajax .Net Engine) | Alternatives for Workflow Integration | ![]() |
Knowledge Builder web applications can communicate with other applications in 3 ways:
Using Dynamic Link Libraries (DLLs)
Using Open Database Connectivity (ODBC)
Using Windows COM Objects
Using Text Files
@URLfetch
@XMLfetch and @XMLpost
Running Ajax in an IFrame
XpertRule Knowledge Builder Ajax .Net runtime can be embedded in an iFrame on a parent Web Page, provided both are hosted on the same domain. The HTML required to achieve this would look something like the following:
<iframe src="http://www.mydomianname.com/ajax/ajax.html" width="713px" height="400px" frameborder="0" allowTransparency="true"></iframe>
Running Knowledge Builder applications in an iFrame gives the workflow integrator the opportunity to pre-capture data (possibly via a query to a server) in the parent page, passing this data to the engine for use in inference and then retrieving values from inference at the end.
Passing data at the start of inference
Inference is invoked by the ajax.html web page. This page is actually produced by the XpertRule Knowledge Builder deployment wizard from the ajax-template.html file in the knowledge builder folder. This ajax-template.html file is the key to integrating into a workflow. The following is a line of code from the file:
var startParams = '' ; // Build up this string…
As the comment suggests, this string is used to populate any objects with specific values at the start of inference. The syntax of the string is as follows:
<object name>=<value>{&<object name>=<value>}
So if out knowledge base has 2 objects ( e.g. Grade and Cost ) and we wished to populate these statically at the start of inference then the string might look something like this:
var startParams = 'Grade=Director&Cost=57' ;
This string can be populated dynamically via the iFrame technique described previously.
Retrieving data at the end of inference
When Knowledge Builder inference is finished, the Ajax .Net engine calls the following function on the ajax.html page:
function BuildEndHTML(data) // Attributes listed in ...
{
var questionIdx = 0 ;
var answerIdx = 1 ;
var el = document.getElementById("eoi");
if ( el != null )
{
el.innerHTML = '<h2>End Of Inference</h2>' +
'<p><strong>Answers:</strong></p>'
for (var row=0;row<data.length;row++)
el . innerHTML += ' ' + data[row][questionIdx] +
' = ' + data[row][answerIdx] + '</br>' ;
}
}
As you can see, there is already sample code to display the inference results in the browser. The values are returned in a 2 dimensional Javascript array. Only XpertRule objects listed in the Knowledge Module's Exposed Objects list are returned. Again, these values could be passed to a parent page via the IFrame technique described previously.